'use strict'

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
	const { router, controller } = app
	router.get('/', controller.users.index)

	/**
	 * 月考复习接口
	 *
	 */
	router.get('/api/oauth/redirect', controller.mouth.auth)

	// 邮件发送接口

	router.get('/api/nodeEmail', controller.mouth.nodeEmail)
	router.get('/api/imgArr', controller.mouth.ossUploadPage)
	router.post('/api/mouthUpload', controller.mouth.upload)
	// router.post('/api/mouthUpload', controller.mouth.fileUpload)
	// 博客列表接口
	router.get('/api/blogsList', controller.mouth.blogsList)
	//
	router.get('/api/blogsDetail', controller.mouth.blogsDetail)

	// 添加评论接口
	router.post('/api/addComments', controller.mouth.addComments)
	// 添加二级评论接口 addSubComments
	router.post('/api/addSubComments', controller.mouth.addSubComments)
	// 获取评论列表接口
	router.get('/api/comments', controller.mouth.blogsComments)
	router.post('/api/login-mouth', controller.mouth.login)

	router.get('/api/search-mouth', controller.mouth.search)

	// router.post

	/**
	 * @title user表
	 * 1. 登陆
	 * 2. 注册
	 * mid: auth / print
	 */
	router.post('/api/login', controller.users.login)
	router.post('/api/register', controller.users.register)
	router.get('/api/findUsers', controller.users.findUsers)

	/**
	 * @title blogs表
	 * 1. 增加
	 * 2. 删除
	 * 3. 查 （分页 、 模糊搜索、排序）
	 * 4. 修改 （）
	 */
	router.get('/api/findBlogs', controller.blogs.findBlogs)
	router.post('/api/addBlogItem', controller.blogs.addBlogItem)
	// addBlogItem
	// searchBlogs
	router.get('/api/searchBlogs', controller.blogs.searchBlogs)
	// removeBlogItem
	router.delete('/api/removeBlogItem/:blogsId', controller.blogs.removeBlogItem)
	// updateBlogItem
	router.put('/api/updateBlogItem/:blogsId', controller.blogs.updateBlogItem)

	/**
	 * @title comments表
	 * 1. 增加
	 * 2. 删除
	 * 3. 查 （分页 、 模糊搜索、排序）
	 * 4. 修改 （）
	 */
	router.post('/api/addComments', controller.comments.addComments)
	// removeComments
	router.delete(
		'/api/removeComments/:commentsId',
		controller.comments.removeComments
	)
	// updateComments
	router.put(
		'/api/updateComments/:commentsId',
		controller.comments.updateComments
	)
	//queryComments
	router.get('/api/queryComments', controller.comments.queryComments)

	/**
	 * 第三方登录
	 */
	// router.get('/api/oauth/redirect', controller.oauth.auth)

	router.get('/api/test', controller.oauth.redirectAuth)

	router.get('/api/oauth/redirect', controller.authTwo.auth)

	/**
	 * @title oss上传图片
	 * 1. npm i egg-oss -S
	 * 2. 配置 egg-oss配置
	 *
	 * 1. post 上传接口
	 * 2. delete 删除接口
	 * 3. get 下载
	 *
	 */
	// 增
	router.post('/api/upload', controller.upload.upload)
	// 删
	router.delete('/api/deleteFile', controller.upload.deleteFile)
	// 查
	router.get('/api/downLoadFile', controller.upload.downLoadFile)

	/**
	 * csrf: 安全策略演示代码
	 *
	 */

	router.post('/api/csrf-test', controller.csrf.csrfTest)

	/**
	 * 学生版 上传
	 */
	router.post('/api/upload_stu', controller.uploadStu.upload)
	router.delete('/api/deleteImage', controller.uploadStu.deleteImage)
	// downloadImage
	router.post('/api/downloadImage', controller.uploadStu.downloadImage)
	// imageList
	router.get('/api/imageList', controller.uploadStu.imageList)

	/**
	 *
	 */
	router.post('/api/fileUpload', controller.file.upload)
	router.delete('/api/delImage', controller.file.delete)
	router.get('/api/down', controller.file.download)
}
